<template>
  <MainLayout
    :role-name="'质检员'"
    :system-title="'质检管理系统'"
    :base-route-path= loginInfo.redirectUrl
    :user-name=userInfo.name
  >
    <template #menu-items>
      <el-menu-item index="/inspector/home">
        <el-icon style="color: #fff;"><HomeFilled /></el-icon>
        <span style="color: #fff;">首页</span>
      </el-menu-item>
      <el-sub-menu index="1">
        <template #title>
          <el-icon style="color: #fff;"><User /></el-icon>
          <span style="color: #fff;">质检录入</span>
        </template>
        <el-menu-item index="/inspector/raw-material-standard">
          <el-icon style="color: #fff;"><Document /></el-icon>
          <span style="color: #fff;">原材料质检录入</span>
        </el-menu-item>
        <el-menu-item index="/inspector/semi-finished-standard">
          <el-icon style="color: #fff;"><Tickets /></el-icon>
          <span style="color: #fff;">半成品质检录入</span>
        </el-menu-item>
        <el-menu-item index="/inspector/finished-standard">
          <el-icon style="color: #fff;"><DataAnalysis /></el-icon>
          <span style="color: #fff;">成品质检录入</span>
        </el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="2">
        <template #title>
          <el-icon style="color: #fff;"><Edit /></el-icon>
          <span style="color: #fff;">老化测试</span>
        </template>
        <el-menu-item index="/inspector/aging-test-home">
          <el-icon style="color: #fff;"><HomeFilled /></el-icon>
          <span style="color: #fff;">老化测试首页</span>
        </el-menu-item>
        <el-menu-item index="/inspector/aging-test-trend">
          <el-icon style="color: #fff;"><DataAnalysis /></el-icon>
          <span style="color: #fff;">老化趋势报告</span>
        </el-menu-item>
        <el-menu-item index="/inspector/aging-test-add">
          <el-icon style="color: #fff;"><DocumentAdd /></el-icon>
          <span style="color: #fff;">老化测试添加</span>
        </el-menu-item>
      </el-sub-menu>
    </template>
  </MainLayout>
</template>

<script setup lang="ts">
import MainLayout from '@/components/layout/MainLayout.vue'
import {
  HomeFilled,
  User,
  Document,
  Tickets,
  DataAnalysis,
  Edit,
  DocumentAdd
} from '@element-plus/icons-vue'
import { userInfoStore } from '@/stores/userInfo';
import { loginInfoStore } from '@/stores/loginInfo';
import { getUserInfoService } from '@/api/UsersApi.ts';
import { ElMessage } from 'element-plus';

const userInfo = userInfoStore();
const loginInfo = loginInfoStore();

const getUserInfo = async () =>{
  let result = await getUserInfoService();
  //将用户信息保存到仓库中
  userInfo.setUserInfo(result.data);
}

//当打开页面时获取当前用户基本信息
getUserInfo();

</script>